package by.alex.dzeshko.lastfmsimple.api;

public class LastFmApi {

	private static final String URL = "http://ws.audioscrobbler.com/2.0/?%s%s%s";

	private static final String METHOD_ALBUM_SEARCH = "method=album.search&album=";

	private static final String METHOD_ARTIST_SEARCH = "method=artist.search&artist=";

	private static final String METHOD_TRACK_SEARCH = "method=track.search&track=";

	private static final String METHOD_ALBUM_GETINFO = "method=album.getinfo";

	private static final String METHOD_ARTIST_GETINFO = "method=artist.getinfo&mbid=";

	private static final String METHOD_ARTIST_GETALBUMS = "method=artist.gettopalbums";

	private static final String KEY_FORMAT = "&api_key=b9f11f7cb8161d2e33304a925df16a7e&format=json";

	public static String searchAlbum(String query) {
		return String.format(URL, METHOD_ALBUM_SEARCH,
				query.trim().replace(" ", "_"), KEY_FORMAT);
	}

	public static String searchArtist(String query) {
		return String.format(URL, METHOD_ARTIST_SEARCH,
				query.trim().replace(" ", "_"), KEY_FORMAT);
	}

	public static String searchTrack(String query) {
		return String.format(URL, METHOD_TRACK_SEARCH,
				query.trim().replace(" ", "_"), KEY_FORMAT);
	}

	public static String getAlbumInfo(String mbid) {
		return String.format(URL, METHOD_ALBUM_GETINFO, "&mbid=" + mbid,
				KEY_FORMAT);
	}

	//
	public static String getAlbumInfo(String artist, String album) {
		return String.format(URL, METHOD_ALBUM_GETINFO, "&artist=" + artist
				+ "&album=" + album, KEY_FORMAT);
	}

	public static String getArtistInfo(String mbid) {
		return String.format(URL, METHOD_ARTIST_GETINFO, mbid, KEY_FORMAT);
	}

	public static String getArtistAlbums(String mbid) {
		return String.format(URL, METHOD_ARTIST_GETALBUMS, "&mbid=" + mbid,
				KEY_FORMAT);
	}

	//
	public static String getArtistAlbumsByName(String artist) {
		return String.format(URL, METHOD_ARTIST_GETALBUMS, "&artist=" + artist,
				KEY_FORMAT);
	}
}
